<?php


if (isset($_GET['action']) && $_GET['action'] == "edit" && isset($_GET['event_id'])) {

	$event_id = $_GET['event_id'];

	$event_item = $event->get($event_id);

	$event_item = $event_item[0];

	$smarty->assign('event_item', $event_item);

	$smarty->display('event_edit.tpl', $_SESSION['uid']);

}elseif (isset($_GET['action']) && $_GET['action'] == "new") {

	$smarty->display('event_edit.tpl', $_SESSION['uid']);

}elseif (isset($_GET['action']) && $_GET['action'] == "remove" && is_allowed(3))  {

	$event_id = $_GET['event_id'];

	$event->remove($event_id);

	$events = $event->get($event_id);

	$smarty->assign('events', $events);

	$smarty->assign('message', "The event has been removed!");

	$smarty->display('event_edit.tpl', $_SESSION['uid']);

}elseif (isset($_POST['action']) && $_POST['action'] == "save") {

    $event_id = $_POST['event_id'];
    $name = $_POST['name'];
    $description = $_POST['description'];

	$event->save($event_id, $name, $description);

	$smarty->assign('message', "The event has been changed/added!");

	$smarty->display('event_edit.tpl', $_SESSION['uid']);

} else {

	$events = $event->get();

	$smarty->assign('events', $events);

	$smarty->display('event_list.tpl', $_SESSION['uid']);

}





?>
